home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!usc!usc!not-for-mail
- From: wawda@alcor.usc.edu (Abu Wawda)
- Newsgroups: comp.lang.c++
- Subject: Why Do I Use An Ampersand in Member Class Parameters?
- Date: 30 Jan 1996 19:33:54 -0800
- Organization: University of Southern California, Los Angeles, CA
- Sender: wawda@alcor.usc.edu
- Distribution: world
- Message-ID: <4emnv2$n5o@alcor.usc.edu>
- NNTP-Posting-Host: alcor.usc.edu
-
- class Simple
- {
- public:
- Simple();
- int operator += (const Simple &);
- private:
- int data;
- };
-
- I have seen many examples of this but I what I don't understand is why
- there is an amersand after Simple? I would wind up implementating the
- function as something like the following:
-
- int Simple::operator += (const Simple ¶meter)
- {
- data += parameter.data;
- }
-
- I mean, I would understand if I parameter were a pointer to a Simple
- class, but that is not the case, since I am not doing:
-
- int Simple::operator += (const Simple ¶meter)
- {
- data += parameter->data;
- }
-
- Then why is there an amersand? I would appreciate any
- suggestions. Thank you!
-
-
- -Abu Wawda
- wawda@scf.usc.edu
-
-
-